package com.example.ya12_13;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.Toast;

import com.tangxiya.ya12_13.Data;
import com.tangxiya.ya12_13.Weather;
import com.tangxiya.ya12_13.API;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        Data.getAPI().getWeather().enqueue(new Callback<Weather>() {
            @Override
            public void onResponse(Call<Weather> call, Response<Weather> response) {
                Weather m = response.body();
                Toast.makeText(MainActivity.this, m.getWeatherinfo().getCity()
                        + m.getWeatherinfo().getTemp(), Toast.LENGTH_SHORT).show();


            }

            @Override
            public void onFailure(Call<Weather> call, Throwable t) {

            }

        });
    }
}